package com.gjy.kafka.k11.producer;

import com.gjy.kafka.k11.KafkaConfig;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;

import java.util.Properties;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

/**
 * ./bin/kafka-console-producer.sh --bootstrap-server 117.72.102.215:9092 --topic streams-word-input
 * ./bin/kafka-console-producer.sh --bootstrap-server 117.72.102.215:9092 --topic streams-word-output
 *
 * @author gjy
 * @version 1.0
 * @since 2025-11-03 14:49:31
 */
public class StreamsProducer {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        Properties properties = KafkaConfig.producer();

        KafkaProducer<String, String> producer = new KafkaProducer<>(properties);
        ProducerRecord<String, String> record = new ProducerRecord<>("streams-word-input", "hello woo Add La d ads");
        Future<RecordMetadata> future = producer.send(record);
        RecordMetadata metadata = future.get();
        System.out.println(metadata);
    }

}
